package com.guigu.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.pojo.Employee;
import com.guigu.pojo.Msg;
import com.guigu.service.EmployeeService;



@Controller
public class EmployeeController extends ExtendsClass {
	@Resource
	EmployeeService employeeService;
	
	@RequestMapping(value="emps",method=RequestMethod.GET)
	@ResponseBody
	public  Msg getEmps(@RequestParam(value="pn",defaultValue="1")Integer pn)
	{
		//获取第pn页，10条内容，默认查询总数count
		PageHelper.startPage(pn, 10);
		List<Employee> list= employeeService.getAll();
		PageInfo<Employee> page = new PageInfo<Employee>(list,5);
		//把返回的對象放在一個map容器中
		return Msg.success().add("pageInfo", page);
	}
	
}
